home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Alles Voor Internet / Tout Pour Internet
/
alles voor internet.iso
/
MacInternet™
/
Telnet
/
NCSA
/
tn3270 2.4d7 source
/
tn3270
/
attnmenu.c
< prev
next >
Wrap
Text File
|
1992-04-17
|
6KB
|
208 lines
/*
* tn3270 for the Macintosh Source Code
* Brown University Computing and Information Services
* Version 2.4d7 April, 1992
* Copyright (c) 1988, 1989, 1990, 1991, 1992 by Brown University and by
* Peter John DiCamillo.
*
* Permission is granted to any individual or institution to use, copy,
* or redistribute the binary version of this software and its
* documentation provided this notice and the copyright notices are
* retained. Permission is granted to any individual or non-profit
* institution to use, copy, modify, or redistribute the source files
* of this software provided this notice and the copyright notices are
* retained. This software may not be distributed for profit, either
* in original form or in derivative works, nor can the source be
* distributed to other than an individual or a non-profit institution.
* Any individual or group interested in seeing and/or using these
* source files but who are prevented from doing so by the above
* constraints should contact Don Wolfe, Assistant Vice-President for
* Computer Systems at Brown University, (401) 863-7250, for possible
* software licensing of the source developed at Brown.
*
* Brown University and Peter John DiCamillo make no representations
* about the suitability of this software for any purpose.
*
* BROWN UNIVERSITY AND PETER JOHN DICAMILLO GIVE NO WARRANTY, EITHER
* EXPRESS OR IMPLIED, FOR THE PROGRAM AND/OR DOCUMENTATION PROVIDED,
* INCLUDING, WITHOUT LIMITATION, WARRANTY OF MERCHANTABILITY AND
* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#if !defined(USEDUMP)
#include "maclib.h"
#include "termdef.h"
#include "tn3270funcs.h"
#include "globals.h"
#else
#pragma load "tn3270DumpFile"
#endif
#pragma segment 3270seg2
extern short attnmousepf;
extern cnr *cdlgcp;
extern PaletteHandle dlgpalette;
extern RGBColor realblack;
pascal void attnmenu(short msg, MenuHandle mhdl, Rect *mr,
Point hit, short *which)
{
Handle mmap;
BitMap menumap;
GrafPtr currport;
static unsigned char coord[3] = {3, 218, 131};
static unsigned char count[3] = {3, 3, 2};
Rect keyrect, whichrect, hitrect;
register short i, j, k, keynum, hitnum;
switch(msg) {
case mDrawMsg:
/* define bitmap for menu */
mmap = GetResource('MMAP', 256);
menumap.baseAddr = *mmap;
menumap.rowBytes = 44;
menumap.bounds.top = 0;
menumap.bounds.left = 0;
menumap.bounds.bottom = 101;
menumap.bounds.right = 343;
/* get current bitmap */
GetPort(&currport);
/* copy bitmap */
CopyBits(&menumap, &(currport->portBits),
&(menumap.bounds), mr, srcCopy, 0L);
if (mhdl == 0) break; /* for dialog call */
/* change to gray if menu not enabled */
if (((*mhdl)->enableFlags && 1) == 0) {
PenMode(notPatBic);
PenPat(&qd.gray);
PaintRect(mr);
PenNormal();
}
break;
case mChooseMsg:
/* enable next line to capture fkey menu in screen dump */
/* if (cs.dblevel) GetNextEvent(keyDownMask, &dbevent); */
/* check for disabled menu */
if (mhdl != 0) /* for dialog call */
if (((*mhdl)->enableFlags && 1) == 0) {
if (*which != 0)
InvertRect(mr);
*which = 0;
break;
}
/* loop through all key rectangles. For each,
check if it is (*which) and if the mouse is
in it */
hitnum = 0;
whichrect.top = 0;
keynum = 1;
for (k=0; k < 3; k++) {
keyrect.top = (*mr).top + 3;
keyrect.bottom = keyrect.top + 23;
for (i=0; i < 4; i++) {
keyrect.left = (*mr).left + coord[k];
keyrect.right = keyrect.left + 40;
for (j=0; j < count[k]; j++) {
if (keynum == (*which)) {
whichrect.top = keyrect.top + 1;
whichrect.left = keyrect.left + 1;
whichrect.bottom = keyrect.bottom - 1;
whichrect.right = keyrect.right - 1;
}
if (PtInRect(hit, &keyrect)) {
hitnum = keynum;
hitrect.top = keyrect.top + 1;
hitrect.left = keyrect.left + 1;
hitrect.bottom = keyrect.bottom - 1;
hitrect.right = keyrect.right - 1;
}
keynum++;
keyrect.left += 41;
keyrect.right += 41;
}
keyrect.top += 24;
keyrect.bottom += 24;
}
}
if (hitnum == 0) {
if (whichrect.top !=0) InvertRect(&whichrect);
(*which) = hitnum;
break;
}
if ((*which) == hitnum) break;
(*which) = hitnum;
if (whichrect.top != 0) InvertRect(&whichrect);
if (hitnum != 0) InvertRect(&hitrect);
break;
case mSizeMsg:
(*mhdl)->menuWidth = 343;
(*mhdl)->menuHeight = 101;
break;
}
}
pascal void attndlg(WindowPtr dlgwindow, short item)
{
GrafPtr gp;
Rect myrect;
short dtype;
Handle ditem;
Point hit;
short which;
GetDItem(dlgwindow, item, &dtype, &ditem, &myrect);
GetPort(&gp);
SetPort(dlgwindow);
hit.v = hit.h = 0;
attnmenu(mDrawMsg, (MenuHandle)0L, &myrect, hit, (short *)0L);
which = attnmousepf;
attnmenu(mChooseMsg, (MenuHandle)0L, &myrect, hit, &which);
SetPort(gp);
}
pascal void colorbox(WindowPtr wp, short inum)
{
#pragma unused (wp)
Rect irect;
short cnum, newcolor;
RGBColor rgbtemp;
cnum = (inum-5)/2; /* 0-9 for white through black, background, status */
irect.top = 5 + (cnum*30);
irect.left = 5;
irect.bottom = irect.top+20;
irect.right = irect.left+95;
FrameRect(&irect);
switch(cnum) {
case 0: newcolor = RGBwhite;
break;
case 1: newcolor = RGByellow;
break;
case 2: newcolor = RGBturquoise;
break;
case 3: newcolor = RGBgreen;
break;
case 4: newcolor = RGBpink;
break;
case 5: newcolor = RGBred;
break;
case 6: newcolor = RGBblue;
break;
case 7: newcolor = RGBblack;
break;
case 8: newcolor = RGBback;
break;
case 9: newcolor = RGBstat;
break;
default: break;
}
GetEntryColor(dlgpalette, newcolor, &rgbtemp);
actualcolor(&rgbtemp, &rgbtemp, cdlgcp);
RGBForeColor(&rgbtemp);
InsetRect(&irect, 1, 1);
PaintRect(&irect);
RGBForeColor(&realblack);
}